package com.kbbywyclient.presenter;

import android.content.Context;

import com.kbbywyclient.data.model.MinePartnerDetailsDataModel;
import com.kbbywyclient.presenter.base.BasePresenter;
import com.kbbywyclient.service.ApiService;
import com.kbbywyclient.service.ApiServiceHelper;
import com.kbbywyclient.ui.contarct.MinePartnerDetailsContract;
import com.kbbywyclient.util.HttpExcUtil;
import com.kbbywyclient.util.RsaJsonUtil;

import javax.inject.Inject;

import rx.Subscriber;

/**
 * Created by Jiangzx on 2017/11/3 16:55.
 */

public class MinePartnerDetailsPresenter extends BasePresenter implements MinePartnerDetailsContract.Presenter {
    @Inject
    Context context;
    @Inject
    ApiService apiService;
    @Inject
    RsaJsonUtil jsonUtil;

    private MinePartnerDetailsContract.View view;

    @Inject
    public MinePartnerDetailsPresenter(MinePartnerDetailsContract.View view){
        this.view=view;
    }

    @Override
    public void loadPartnerDetails(int salesId) {
        jsonUtil.put("sales_id",salesId);
        ApiServiceHelper.
                appointThreadNormal(apiService.getPartnerDetails(jsonUtil.getRsaParams())).
                subscribe(new Subscriber<MinePartnerDetailsDataModel>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        HttpExcUtil.printError(e);
                    }

                    @Override
                    public void onNext(MinePartnerDetailsDataModel minePartnerDetailsDataModel) {
                        view.onPartnerDetailsSuccess(minePartnerDetailsDataModel.getData());
                    }
                });
    }
}
